package com.zzptc.gyc.myapp30;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.zzptc.lzh.myapp30.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main2Activity extends AppCompatActivity {
    GridView gv_menu;
    int[] pic={R.mipmap.a,R.mipmap.b,R.mipmap.c,R.mipmap.d,R.mipmap.e,R.mipmap.f};
    String[] itemName={"微信","QQ","日历","相机","视频","地图"};
    List<Map<String,Object>>list;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        gv_menu = findViewById(R.id.gv_menu);
        list = new ArrayList<>();
        getData();
        String[] form={"tupian","biaoti"};
        int[] to={R.id.iv_pic,R.id.tv_title};

        SimpleAdapter simpleAdapter=new SimpleAdapter(Main2Activity.this,list,R.layout.grid_item2,form,to);
        gv_menu.setAdapter(simpleAdapter);
        }

    private void getData() {
        for (int i=0;i<itemName.length;i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("tupian", pic[i]);
            map.put("biaoti", itemName[i]);
            list.add(map);
    }

  }
}
